/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package view.Kasse;

import controller.SalgsController;
import java.awt.Graphics;
import model.Vare;
import utility.ImageToolbox;

/**
 *
 * @author Jeppe
 */
public class VareIconPanel extends javax.swing.JPanel {
    
    private KassePanel kassePanel;
    private VarePanel varePanel;
    private Vare vare;
    /**
     * Creates new form VareIconPanel
     */
    public VareIconPanel(KassePanel kassePanel, VarePanel varePanel, Vare vare) {
        initComponents();
        this.kassePanel = kassePanel;
        this.varePanel = varePanel;
        this.vare = vare;        
    }

    
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        iconLabel = new javax.swing.JLabel(){
            public void paint(Graphics g){
                ImageToolbox.drawImage(g, vare.getIcon(), 0, 0, iconLabel.getSize().width, iconLabel.getSize().height);
            }
        };
        jButton1 = new javax.swing.JButton();

        setBorder(javax.swing.BorderFactory.createEtchedBorder());
        setOpaque(false);
        setLayout(null);
        add(iconLabel);
        iconLabel.setBounds(0, 0, 130, 130);

        jButton1.setContentAreaFilled(false);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        add(jButton1);
        jButton1.setBounds(0, 0, 130, 130);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        kassePanel.tilføjVareTilSalg(vare);
    }//GEN-LAST:event_jButton1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel iconLabel;
    private javax.swing.JButton jButton1;
    // End of variables declaration//GEN-END:variables
}
